#include "Function.h"
#include <iostream>
#include <iomanip>
#include <strstream>
#include <string>
using namespace std;

int retvalue = 0;
void T(ostream & o, istream & i, int start, int end)
{
	o << 'T';

	W(o, start);
	W(o, end - start, 2);

	o << i.rdbuf() << endl;
}

void M(string & s, int loc, int size, char c, const string & param)
{
	strstream	stream;
	string		temp;

	stream << hex << uppercase << setfill('0');
	stream << 'M' << DELIM << setw(6) << loc << DELIM << setw(2) << size << DELIM << c << param;
	stream >> temp;

	s += temp + '\n';
}

void E(string & s, int loc)
{
	strstream	stream;

	stream << hex << uppercase << setfill('0');
	stream << 'E' << DELIM << setw(6) << loc;
	stream >> s;

	s += '\n';
}

string S(const string & s)
{
	char	c[8];
	int		i, l = TEXT_LENGTH - strlen(s.c_str());

	for (i = 0; i < l; ++i)
		c[i] = ' ';
	c[i] = 0;

	return s + c;
}
